﻿using Loki.Utils;

namespace Loki.IoC
{
    public class ProviderCacheConfiguration<TDataProvider> where TDataProvider : class
    {
        protected TDataProvider Provider
        {
            get { return provider.Value; }
        }

        protected IObjectCreator Context
        {
            get;
            private set;
        }

        private LazyResolver<TDataProvider> provider;

        public ProviderCacheConfiguration(IObjectCreator context)
        {
            Context = context;
            provider = new LazyResolver<TDataProvider>(Context);
        }

        public ProviderCacheConfiguration()
            : this(Toolkit.IoC.DefaultContext)
        {
        }
    }
}